if (inweo.get("inweo.widgets.box") != true) {
	inweo.set("inweo.widgets.box", true);
	inweo.set("inweo.widgets.hbox", true);
	inweo.set("inweo.widgets.vbox", true);
	inweo.widgets.box = inweo.core.widget.extend({
		orient: null,
		spacing: null,
		initialize: function(parent, orient) {
			this.orient = orient || "horizontal";
			if (this.orient == "horizontal") {
				return new inweo.widgets.hbox(parent);
			} else if (this.orient == "vertical") {
				return new inweo.widgets.vbox(parent);
			}
		},
		pack: function(child) {
			var div = new Element("div");
			div.injectInside(this.widget);
			child.__pack(div);
			if (this.spacing != null) {
				div.setStyle("padding", this.spacing);
			}
		},
		space: function(space) {
			if (this.space != null) {
				this.spacing = space;
			} else {
				return this.spacing;
			}
		}
	});
	inweo.widgets.hbox = inweo.widgets.box.extend({
		orient: "horizontal",
		initialize: function(parent) {
			this.widget = new Element("div");
			this.widget.addClass("hbox");
			if ($type(parent) == "element") {
				this.__pack(parent);
			}
			this.registerWidget("hbox");
		},
		pack: function(parent) {
			this.parent(parent);
			var br = null;
			this.widget.getChildren().each(function(div) {
				if (div.hasClass("box-br") == true) {
					br = div;
				}
			});
			if (br == null) {
				br = new Element("div");
				br.addClass("box-br");
			}
			br.injectInside(this.widget);
		}
	});
	inweo.widgets.vbox = inweo.widgets.box.extend({
		orient: "vertical",
		initialize: function(parent) {
			this.widget = new Element("div");
			this.widget.addClass("vbox");
			if ($type(parent) == "element") {
				this.__pack(parent);
			}
			this.registerWidget("vbox");
		}
	});

	inweo.widgets.box.tag = inweo.core.tag.extend({
		initialize: function(extended) {
			if (extended != true) {
				return new inweo.widgets.hbox.tag();
			}
			inweo.loadCss(inweo.get("path") + "widgets/box/box.css");
		},
		insert: function(element, obj) {
			var div = [];
			$(element).getChildren().each(function(child, i) {
				div[i] = new Element("div");
				div[i].injectInside(obj.widget);
				child.injectInside(div[i]);
			})
			obj.widget.replaces(element);
		}
	});
	inweo.widgets.vbox.tag = inweo.widgets.box.tag.extend({
		initialize: function() {
			this.parent(true);
		}
	});
	inweo.widgets.hbox.tag = inweo.widgets.box.tag.extend({
		initialize: function() {
			this.parent(true);
		},
		insert: function(element, obj) {
			this.parent(element, obj);
			new Element("div").addClass("box-br").injectInside(obj.widget);
		}
	});
}